<!-- 企业认证详情组件 -->
<template>
  <view>
    <view class="flex items-center c-#fff text-28 w-full h-80 pl-4" :class="[`${statusBgColor}`]">{{ statusDesc }}</view>
    <view class="px-4 pt-3 pb-20">
      <view class="flex items-center py-3 text-28 c-#333 u-border-bottom">
        <view class="flex-shrink-0 font-bold">企业名称</view>
        <view class="flex-1 text-right">{{ data.company_name || '' }}</view>
      </view>
      <view class="flex items-center py-3 text-28 c-#333 u-border-bottom">
        <view class="flex-shrink-0 font-bold">统一社会信用代码</view>
        <view class="flex-1 text-right">{{ data.credit_code || '' }}</view>
      </view>
      <view class="flex items-center py-3 text-28 c-#333 u-border-bottom">
        <view class="flex-shrink-0 font-bold">法定代表人</view>
        <view class="flex-1 text-right">{{ data.legal_person || '' }}</view>
      </view>
      <view class="flex justify-between py-3 text-28 c-#333">
        <view class="flex-shrink-0 font-bold">营业执照</view>
        <u-image :src="data.business_license" width="446" height="296" border-radius="12"
          @click="previewImage([data.business_license], 0)" />
      </view>
    </view>
    <view v-if="data.audit_status!=1" class="bottom-wrap-16 bg-white">
      <u-line class="w-full" color="#eee" :hair-line="false" />
      <view class="btn-submit mt-1" @click="emit('reSubmit')">再次{{ data.audit_status == 2 ? '提交': '编辑' }}</view>
    </view>
  </view>
</template>

<script setup>
import { previewImage } from '@/common/util/uni';
const emit = defineEmits(['reSubmit'])
const props = defineProps({
  data: Object
})

const bgColorList = [
  { bgColor: 'bg-audit', desc: '已提交企业认证材料，正在审核中~', value: 0 },
  { bgColor: 'bg-success', desc: '已通过企业认证~', value: 1 },
  { bgColor: 'bg-fail', desc: '审核失败：', value: 2 },
]

// 状态提示语背景色
const statusBgColor = computed(() => {
  return bgColorList.find(v => v.value == props.data.audit_status)?.bgColor ?? '#F4AF22'
})
// 状态提示语
const statusDesc = computed(() => {
  return props.data.audit_status==2?`审核失败：${props.data.fail_reason}`: bgColorList.find(v => v.value == props.data.audit_status)?.desc
})
</script>

<style lang='scss' scoped>
.bg-audit {
  background-color: #F4AF22;
}

.bg-fail {
  background-color: #FF513A;
}

.bg-success {
  background-color: #3FB352;
}
</style>
